home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / text / misc / TextInfo.lha / TextInfo / TextInfo.doc < prev   
Text File  |  1997-12-16  |  16KB  |  379 lines

  1.  
  2. **********************************************************************
  3. *         TextInfo 1.01, by Erik Spåre (Parsec/Phuture 303)          *
  4. *   Filematching routines by Anders Vedmar (Axehandle/Phuture 303)   *
  5. **********************************************************************
  6.  
  7. IS THIS A PROGRAM FOR YOU?
  8.  
  9.     TextInfo's task is to count all the various _unique_ words in texts
  10.     and list them.  "Mine your mine" = 3 words, 2 unique (mine, your).
  11.     Read.  If you find the following facts interesting, then this may
  12.     be a program for you.
  13.  
  14.     !  Two Cities by Dickens has almost twice as many unique words
  15.     as the Koran, despite the fact that the Koran is bigger.  (Two
  16.     Cities 8041/138384, Koran 4300/152164).  Plato's the Republic
  17.     (translated, as the Koran) has 45 % more (6199/127005).
  18.  
  19.     !  Moby Dick has 13403/213486 words; that is 27 % more than
  20.     the Bible's 10560/812394, even though Moby Dick's size is only
  21.     about one quarter of the Bible's!
  22.  
  23.     !  A friend (greetings, Théonore) told me that he had heard that
  24.     there was a word in the Bible that occured 666 times, and it
  25.     was the name of the Beast.  There is no such word in King
  26.     James Bible... :(
  27.  
  28.     !  You need only to know the meaning of 48 words to understand
  29.     half of the words written in the Bible...  (37 in the Koran,
  30.     44 in the Republic, 64 in Two Cities and 87 in Moby Dick).
  31.  
  32.     It is indeed as Axehandle said:  "One would have supposed that Alah
  33.     had a bigger vocabulary..."
  34.  
  35.  
  36. TEXTINFO IS...
  37.  
  38.     100 % Assembler
  39.     Freeware
  40.  
  41.  
  42. REQUIREMENTS
  43.  
  44.     OS 2.0+ and a mind that is more interested in how many grains of
  45.     sand the average beach contains, than the latest sport results or
  46.     soap operas.
  47.  
  48.  
  49. INTRODUCTION
  50.  
  51.     "`Don't be afraid to hear me.  Don't shrink from anything I say. I
  52.     am like one who died young.  All my life might have been.'
  53.       `Is it not--forgive me; I have begun the question on my lips--a
  54.     pity to live no better life?'
  55.       `God knows it is a shame!'"
  56.       / Charles Dickens, Two Cities.
  57.  
  58.     "Here is wisdom.  Let him that hath understanding count the number
  59.     of the beast:  for it is the number of a man; and his number is Six
  60.     hundred threescore and six."
  61.       / The Bible.
  62.  
  63.     "O ye who believe!  Approach not coding while ye are drunk, until
  64.     ye well know what ye type."
  65.       / The Koran.
  66.  
  67.     The idea to this program was given to me one day when I was reading
  68.     the Koran.  It was so amazingly boring, so, naturally, my thoughts
  69.     were not very busy with the text that some low priority subroutine
  70.     of my brain supplied, but with the things I could do after I had
  71.     finished reading the current chapter.  Sometimes I discussed with
  72.     myself how bored I was.
  73.       "Have I ever been this bored?"
  74.       "I don't know."
  75.       "How is it possible to constantly reiterate similar phrases, and
  76.     call the result wisdom?"
  77.       "He was probably drinking wine -- laudanum most likely -- and got
  78.     a bit excited."
  79.  
  80.     And one day the idea to this program was born.
  81.       "I wonder how many different words this book contains."
  82.       "Not many, I'm sure."
  83.       "No...  I wonder how many..."
  84.       "Maybe you could count them by a clever program?"
  85.       The program proved me right, needless to say; but it also made
  86.     me interested in other things about etexts, like how many words
  87.     that is responsible for a certain percentage of the word total...
  88.     The idea to release this program seemed in the beginning a bit
  89.     absurd -- why would anyone use it? -- but now...  I don't think
  90.     that just I and Axehandle find things like this interesting.
  91.     
  92.  
  93. WHAT DOES THE PROGRAM DO?
  94.  
  95.     It goes through textfiles, counts the bytes, letters, words, unique
  96.     words and more.  Here is a sample of a list that was produced from
  97.     all the textfiles (not exceeding 5MB) on the CD Project Gutenberg
  98.     (Nov 94).
  99.  
  100.     Bytes read           91502237   Total amount of bytes read
  101.     Letters              61101533   Total amount of letters
  102.     Words                13925117   Total amount of words
  103.     Unique                  94816   Number of unique words
  104.     Subsumes                19681   Words with word-stem + ending
  105.     Syllabications           7210   Executed syllabications
  106.     Truncated chars           294   Chars exceeding max wordlength
  107.     Truncated words            27   Words that were too long
  108.     Examined file/s           204   Files that matched
  109.  
  110.     the                    791561   After the above info, the list
  111.     and                    496698   of words follow. Unless
  112.     of                     440919   specified otherwise, all the
  113.     ...                             unique words are listed.
  114.     zygote                      1
  115.     zyuganov                    1
  116.  
  117.     aarons(1)=aaron                 Following the wordlist is the
  118.     abhorred(79)=abhorr             subsume report. The number
  119.     abominations(246)=abomination   within paranthesis is how many
  120.     ...                             times the word with ending
  121.     zulus(1)=zulu                   occured, before it was
  122.     zugs(1)=zug                     subsumed to its wordstem.
  123.  
  124.      5 %          1                 Finally there's the percentage
  125.     10 %          3                 list. The third line here
  126.     15 %          5                 means that you only need to
  127.     ...                             know 5 words to understand
  128.     90 %       4045                 15 % of all the words that
  129.     95 %       8606                 was examined.
  130.  
  131.  
  132. WHAT IS IT USEFUL FOR?
  133.  
  134.     Apart from giving you swarms of interesting arrows, it is not very
  135.     useful.  It will tell you how big your vocabulary is (try comparing
  136.     the unique words found (with subsuming disabled) in your letters,
  137.     written in your native language versus english.)
  138.       If words like "fuck", "lame" or "cool" tops your letters, then
  139.     maybe you should consider blushing...
  140.  
  141.     If you are curious about a certain etext, check the first noun; it
  142.     will in many cases tell you the whole plot.  I have tried this on
  143.     five etexts...
  144.  
  145.     NAME            MOST COMMON NONE
  146.     Alice in Wonderland    alice
  147.     Hacker's Crackdown    computer
  148.     Moby Dick        whale
  149.     The Bible        lord
  150.     The Koran        god
  151.  
  152.     If you have lots of texts in a foreign language that you wish to
  153.     study, it could be a good idea to "start from the top"...  Let's
  154.     say that you didn't understand a word english, that your favourite
  155.     author was Lewis Carol, and that you would love to read "Alice in
  156.     Wonderland" as it was once originally written.  Alice in Wonderland
  157.     is 150 kb, and 1083 words = 95 % of it; if the Gutenberg results
  158.     represents the english language (where 95 % = 8606 words) you would
  159.     "spare" more than 7000 words if you used this method.  Hmm...
  160.  
  161. THE ARGUMENT LINE
  162.  
  163.     All options are case sensitive. 
  164.     Usage: TextInfo [-<OPTIONS>] <FILE/PATH> <DESTFILE> [ALL]
  165.  
  166.         <FILE/PATH> is either a file or a file pattern.
  167.     <DESTFILE> is the name of the output file.
  168.     ALL is to be used when you want recursive matching.
  169.  
  170.     Options
  171.  
  172.     -s  Disable syllabication
  173.         This will disable syllabication.  By default syllabication
  174.         is used, meaning that words that do not fit on one line,
  175.         and thus are separated by a hyphen, will be connected and
  176.         treated as one word.  For instance "norr-[NEW LINE]sken"
  177.         will be listed as "norrsken" when syllabication is on;
  178.         otherwise it becomes 2 separate words.  Same thing with
  179.         "norr-[NEW LINE]-sken" or even "norr-[NEW LINE]   sken".
  180.         The only thing the syllabication routine requires is a
  181.         letter followed by a hyphen and a new line (CR and/or LF);
  182.         it will then connect the first found letter or letters.
  183.         There is one thing that will abort the syllabication, and
  184.         that is when another hyphen is found within the word that
  185.         is to be connected.  E g "bread-[NEW LINE]and-butter" will
  186.         be treated as three words.  This is not allways good...
  187.  
  188.     -e  Disable subsuming
  189.         Use this if you want subsuming to be disabled.  Subsuming
  190.         is by default conducted on all the words that end on `s',
  191.         `ed' or `ing', if, and only if, the stem-word is found.
  192.         In "I have walked there, now I walk here" the word
  193.         `walked' ends on `ed', and since its word-stem `walk' also
  194.         is present, the word is subsumed to `walk'.  But in "I
  195.         like stars" `stars' is not subsumed to `star' since the
  196.         word-stem is not present.  The word-stem has to be at
  197.         least three chars, so `his' in "I said hi to...  what's
  198.         his name..." won't be subsumed to `hi'.  Subsuming is not
  199.         always correct, it would take a dictionary to make it
  200.         safe; for instance `cared' in "My boyfriend really cared
  201.         for me in his car" will uncorrectly be subsumed to car...
  202.         That's why there's a subsume report.
  203.  
  204.     -e<e1>,... Set endings to subsume
  205.            This works as the above option (in fact, it is the
  206.         same), it disables the default subsuming, but conducts
  207.         subsuming on words with the endings that you specify.  For
  208.         instance "-eed,s,er" will perform subsuming on words
  209.         ending with ed, s or er. There are 210 bytes reserved for
  210.         the endings, then comes the percentages txt (in memory)...
  211.  
  212.     -r  Disable subsume report
  213.           Use this option if you do not want a subsume report in the
  214.              output file.
  215.  
  216.     -p  Disable percentage list
  217.         This option will disable the percentage listing in the
  218.         output file.  By default the amount of words that make up
  219.         for 5, 10, 15...upto 95 percent of the total sum of words,
  220.         is listed in the end.  I haven't checked this routine very
  221.         much, so I am not 100 % sure that all the values are
  222.         correct.
  223.  
  224.     -n[<n>] Set number of words to list
  225.             Use this option to set the number of words to list in
  226.         the output file.  This does not affect the subsume report.
  227.         Note:  -n alone will disable the word list.
  228.  
  229.     -l<n> Set lowest number to list.
  230.           The number n is required and tells the program to only
  231.         list words that occured n times or more.  If you would
  232.         write "-l10000" only words that occured 10 thousand times
  233.         or more will be listed.
  234.  
  235.     -m[<kb>] Set minimum filesize
  236.          By default this is set to 50 bytes; that means that
  237.         files smaller than 50 bytes will not be examined.  If you
  238.         don't specify a number, all sizes will be valid, else the
  239.         minumum size is set to 1000*<kb> bytes.
  240.  
  241.     -M<kb> Set maximum filesize
  242.            As the -m option, but here you _must_ specify a kb
  243.         value.  Files exceeding this size will not be loaded.
  244.  
  245.     -t<t>,<s> Set number of tabs,size
  246.           By default the output words are displayed with a
  247.         width of 24 chars, or 3 tabs with the size of 8.  The
  248.         maximum wordlength is derived from these numbers --
  249.         maxlen = tabs*tabsize-1. Number of tabs may not exceed
  250.         9, tabsize may not exceed 99.
  251.  
  252.     -z  Don't abort on zero
  253.         A textfile shouldn't contain the ascii value zero (except
  254.         maybe as EOF-sign) therefore textinfo will by default stop
  255.         the examination whenever zero occurs.  Use the -z option
  256.         to force the program to process all bytes in all files;
  257.         this is useful if you have wordprocessor files, with long
  258.         headers (bound to hide a zero somewhere).
  259.  
  260.  
  261. RUNNING TEXTINFO
  262.  
  263.     When textinfo is started, this is what will happen.  First the
  264.     argument line is checked; if it is invalid the program will exit
  265.     with the short information text.  If everything is ok the
  266.     destination file will now be opened (and immediately closed) just
  267.     to make sure this won't fail after an hour of intense counting.
  268.       Now all the files that match the given pattern is checked to
  269.     determine the maximum filesize; this amount of memory is then
  270.     allocated.  If there is not enough memory, the program will exit
  271.     with an error message.
  272.  
  273.     This is when the real program starts.  The first matching file
  274.     will be loaded to the already allocated memory.  (Initially I
  275.     allocated a memory block just as large as the current file,
  276.     processed it, and then freed it, but this turned out to make the
  277.     memory heavily fragmented, and in the end there was seldom enough
  278.     memory for the (often huge) final wordlist and output file).
  279.       The file will be pre-examined in two passes.  In the first pass
  280.     the whole file will be lowercased and all non-letters will be set
  281.     to zero.  If syllabication is wanted, this will be done here.  In
  282.     the second pass _all_ words will be counted and in the same time
  283.     truncated if they exceed the maximum allowed wordlength.  There is
  284.     no progress indicator for this, because it doesn't take much time.
  285.  
  286.     Now the file is safe to examine, and the main routine is called.
  287.     It will check a word at a time; if the word has occured before, its
  288.     counter will be incremented; if it is a new word, it will be added
  289.     and given a counter set to 1.  Every 256:th word, the progress
  290.     indicator will be updated.
  291.       When this is done, two numbers will be displayed:  the first is
  292.     the amount of words the file contained; the second is how many of
  293.     them that had not been found before.  The program then loads the
  294.     next matching file.
  295.  
  296.     When all files have been examined, the memoryblock used for the
  297.     loaded files is freed.  The subsuming is now executed, unless it is
  298.     disabled.  After this the result is rearranged into a large
  299.     wordlist.  This wordlist is then sorted; all the words that occured
  300.     255 times or less is sorted instantly, the rest is bubble sorted.
  301.     If you have, say 20 thousand words, that appeared more than 255
  302.     times, this will take some time, but normally you will hardly
  303.     notice the sorting.
  304.       The words are sorted in order of frequency, with the most usual
  305.     word (probably `the') in the top.  Words that occured an equal
  306.     amount of times is sorted after their first 2 characters.  Why only
  307.     the first two?  Because it is just a side-effect of the counting
  308.     routine (a nice one for a change!).  Although this means that the
  309.     listing is in ascii-order, so swedish texts (for instance) will
  310.     unfortunally be listed with the ä-words before the å-ones.  Ah
  311.     well!
  312.       Finally the output file will be created and written to the
  313.     destination.
  314.  
  315.  
  316. ABOUT THE CODE...
  317.  
  318.     I do not wish to brag, so let me just say that the main routine for
  319.     counting the various words is amazingly fast.  (Right Axehandle?)
  320.     However, the additional (boring) routines for making everything
  321.     foolproof, and the progress display, have slowed it down somewhat.
  322.     Still, if you disable syllabication and subsuming, counting and
  323.     sorting all the words in the Koran (0.8MB) and creating an output
  324.     file takes only 8 seconds on my A1200 (slightly more than half the
  325.     time Dopus needed just to count the lines).  The Bible (66 files with
  326.     a total of about 4.6MB) takes 50 seconds.  (My first version of
  327.     this program needed 45 minutes to go through the Koran!  The second
  328.     version was a bit more efficient, and actually 29 THOUSAND percent
  329.     faster (before optimization)!  A ratio that would make any
  330.     programmer drool...)
  331.          The subsume routine has not been optimized.
  332.  
  333.  
  334. BUGS???
  335.  
  336.     I have never encountered any bugs in this version.  However, I have
  337.     only been able to check 90 MB texts at a time, so I cannot be
  338.     completely sure how it works on say 1GB of data.  The number
  339.     displays can only handle 10 digits, or one unsigned longword.
  340.  
  341.  
  342. THE PHUTURE
  343.  
  344.     There will probably not be any update on this program, unless I get
  345.     one single request from some unknown textinfo user (that's all the
  346.     motivation I need!).
  347.       It has been suggested to me by Axehandle, that there should be an
  348.     option to add results to an already existing wordlist.  That way it
  349.     would be possible to create one huge wordlist formed by many, many
  350.     CD-Roms.
  351.       XPK/LZX/LHA/ZIP support would also be very useful, since most
  352.     CD:s pack their texts.
  353.  
  354.  
  355. CONTACT ME...
  356.  
  357.     If you want an update made, or something else, write...
  358.  
  359.     EMail:    parsec@aljan.com.au (valid to end of mars 1998,
  360.         after that use: blodskam@hotmail.com)
  361.     
  362.     I have, btw, used the handle Parsec since the summer of 1991. I know
  363.     many people think handles are silly (albeit /nicks are "kewl"), but...
  364.     It's a silly life! Take it seriousley, and *you* are the fool!
  365.  
  366.  
  367. HISTORY
  368.  
  369.     v1.0 (960320)
  370.  
  371.     ** First public release
  372.  
  373.     v1.01 (971217)
  374.  
  375.     ** According to a friend (Thomas Richter I believe) TextInfo
  376.     would crash if no endquoute was found in the filepattern.
  377.     Fixed this.
  378.  
  379.